cmake_minimum_required(VERSION 3.8)
project(mimic_joint_plugin)

if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID MATCHES "Clang")
  add_compile_options(-Wall -Wextra -Wpedantic)
endif()

# =======================
# find dependencies
# =======================
find_package(ament_cmake REQUIRED)
find_package(rclcpp REQUIRED)
find_package(gazebo_dev REQUIRED)
find_package(gazebo_ros REQUIRED)

include_directories(
  include
  ${GAZEBO_INCLUDE_DIRS}
  ${rclcpp_INCLUDE_DIRS}
  ${gazebo_ros_INCLUDE_DIRS}
)

link_directories(${GAZEBO_LIBRARY_DIRS})

# =======================
# 插件源码
# =======================
add_library(${PROJECT_NAME} SHARED
  src/mimic_joint_plugin.cpp
)

ament_target_dependencies(${PROJECT_NAME}
  rclcpp
  gazebo_ros
)

target_link_libraries(${PROJECT_NAME}
  ${GAZEBO_LIBRARIES}
)

# =======================
# 安装
# =======================
install(
  TARGETS ${PROJECT_NAME}
  LIBRARY DESTINATION lib
)

# =======================
# 测试
# =======================
if(BUILD_TESTING)
  find_package(ament_lint_auto REQUIRED)
  set(ament_cmake_copyright_FOUND TRUE)
  set(ament_cmake_cpplint_FOUND TRUE)
  ament_lint_auto_find_test_dependencies()
endif()

ament_export_libraries(${PROJECT_NAME})
ament_package()
